// Let's make <Drag text='Write the docs' /> draggable!

import React from 'react';
import DragM from 'dragm';
// import styles from './index.less';
// import { Button } from 'antd';

interface IPropsType {
  title: React.ReactNode | string;
  className: any;
}

export default class BuildTitle extends React.Component<IPropsType> {
  // updateTransform = transformStr => {
  //   for(let i=0;i<this.modalDom.length;i++){
  //     this.modalDom[i].style.transform = transformStr;
  //   }
  // };
  modalDom: any;

  updateTransform = (transformStr: any) => {
    let modalDom: any = document.getElementsByClassName(
      this.props.className, //modal的class是ant-modal-wrap
    )[0]?.parentNode;

    modalDom.style.transform = transformStr;
  };

  // componentDidMount() {
  //   this.modalDom = document.getElementsByClassName(
  //     "ant-modal" //modal的class是ant-modal
  //   );
  // }

  // componentWillReceiveProps(nextProps) {
  //   const visible = nextProps.visible;
  //   if(!visible){
  //     for(let i=0;i<this.modalDom.length;i++){
  //       this.updateTransform("none");
  //     }
  //   }
  // }

  componentDidMount() {
    // this.modalDom = document.getElementsByClassName("ant-modal-wrap" //modal的class是ant-modal-wrap
    // )[0].parentNode;
    // let { className } = this.props;
    // this.modalDom = document.getElementsByClassName(
    //   className, //modal的class是ant-modal-wrap
    // )[0]?.parentNode;
  }

  render() {
    const { title } = this.props;
    return (
      <DragM updateTransform={this.updateTransform}>
        <div>{title}</div>
      </DragM>
    );
  }
}
